home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 76 / DVD Actual 1 Marzo 2003.iso / Trial / TurboCAD 7.1 Pro / Data.Cab / F29322_PaperOrientation.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-10  |  4.3 KB  |  163 lines

  1. // PaperOrientation.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "resource.h"
  6. #include "PaperOrientation.h"
  7. #include "PaperSpaceWizard.h"
  8.  
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CPaperOrientation property page
  17.  
  18. IMPLEMENT_DYNCREATE(CPaperOrientation, CPropertyPage)
  19.  
  20. CPaperOrientation::CPaperOrientation() : CPropertyPage(CPaperOrientation::IDD)
  21. {
  22.     //{{AFX_DATA_INIT(CPaperOrientation)
  23.         // NOTE: the ClassWizard will add member initialization here
  24.     //}}AFX_DATA_INIT
  25. }
  26.  
  27. CPaperOrientation::~CPaperOrientation()
  28. {
  29. }
  30.  
  31. void CPaperOrientation::DoDataExchange(CDataExchange* pDX)
  32. {
  33.     CPropertyPage::DoDataExchange(pDX);
  34.     //{{AFX_DATA_MAP(CPaperOrientation)
  35.         // NOTE: the ClassWizard will add DDX and DDV calls here
  36.     //}}AFX_DATA_MAP
  37. }
  38.  
  39.  
  40. BEGIN_MESSAGE_MAP(CPaperOrientation, CPropertyPage)
  41.     //{{AFX_MSG_MAP(CPaperOrientation)
  42.     ON_BN_CLICKED(IDC_PORIENTATIONP, OnPorientationp)
  43.     ON_BN_CLICKED(IDC_PORIENTATIONL, OnPorientationl)
  44.     //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CPaperOrientation message handlers
  49.  
  50. BOOL CPaperOrientation::OnSetActive() 
  51. {
  52. //    CPropertySheet* pSheet = (CPropertySheet*)GetParent();
  53.     CPaperSpaceWizard* pSheet = (CPaperSpaceWizard*)GetParent();
  54.  
  55.     ASSERT_KINDOF(CPropertySheet, pSheet);
  56.     pSheet->SetWizardButtons( PSWIZB_BACK | PSWIZB_FINISH);
  57.     LPTSTR IDB;
  58.     CButton *pRadioB = (CButton *) GetDlgItem(IDC_PORIENTATIONL);
  59.     CButton *pRadioB1 = (CButton *) GetDlgItem(IDC_PORIENTATIONP);
  60.     CStatic *pPaperPreview = (CStatic *) GetDlgItem(IDC_PAPERPREVIEW);
  61.  
  62.  
  63.     if (pSheet->m_PSInfo->bPaperOrientation == 0)
  64.     {
  65.         IDB = MAKEINTRESOURCE(IDI_ICONP);
  66.         pRadioB1->SetCheck(1);
  67.         pRadioB->SetCheck(0);
  68.     }
  69.     else
  70.     {
  71.         IDB = MAKEINTRESOURCE(IDI_ICONL);
  72.         pRadioB1->SetCheck(0);
  73.         pRadioB->SetCheck(1);
  74.  
  75.     }
  76.     HICON pIcon = ::LoadIcon (AfxGetResourceHandle(), IDB);
  77.     pPaperPreview->SetIcon (pIcon);
  78. //    int i = DeleteObject(pBmp);    
  79.  
  80. /*
  81.     if (pSheet->m_PSInfo.bPaperOrientation == 0)
  82.         CPaperOrientation::OnPorientationp ();
  83.     else
  84.         CPaperOrientation::OnPorientationl ();
  85. */    
  86.     return CPropertyPage::OnSetActive();
  87. }
  88.  
  89. void CPaperOrientation::OnPorientationp() 
  90. {
  91.     // TODO: Add your control notification handler code here
  92.     LPTSTR IDB;
  93.  
  94.     CButton *pRadioB = (CButton *) GetDlgItem(IDC_PORIENTATIONL);
  95.     pRadioB->SetCheck(0);
  96.     CButton *pRadioB1 = (CButton *) GetDlgItem(IDC_PORIENTATIONP);
  97.     pRadioB1->SetCheck(1);
  98.  
  99.     CStatic *pPaperPreview = (CStatic *) GetDlgItem(IDC_PAPERPREVIEW);
  100.     IDB = MAKEINTRESOURCE(IDI_ICONP);
  101.     HICON pIcon = ::LoadIcon (AfxGetResourceHandle(), IDB);
  102.     pPaperPreview->SetIcon (pIcon);
  103.     int i = DeleteObject(pIcon);    
  104.     CPaperSpaceWizard* pSheet = (CPaperSpaceWizard*)GetParent();
  105.     pSheet->m_PSInfo->bPaperOrientation = 0;
  106. }
  107.  
  108. void CPaperOrientation::OnPorientationl() 
  109. {
  110.     // TODO: Add your control notification handler code here
  111.     LPTSTR IDB;
  112.     CButton *pRadioB = (CButton *) GetDlgItem(IDC_PORIENTATIONP);
  113.     pRadioB->SetCheck(0);
  114.  
  115.     CButton *pRadioB1 = (CButton *) GetDlgItem(IDC_PORIENTATIONL);
  116.     pRadioB1->SetCheck(1);
  117.  
  118.     CStatic *pPaperPreview = (CStatic *) GetDlgItem(IDC_PAPERPREVIEW);
  119.  
  120.     IDB = MAKEINTRESOURCE(IDI_ICONL);
  121. //    HBITMAP pBmp = ::LoadBitmap(AfxGetResourceHandle(), IDB);
  122.     HICON pIcon = ::LoadIcon (AfxGetResourceHandle(), IDB);
  123.     pPaperPreview->SetIcon (pIcon);
  124.     int i = DeleteObject(pIcon);
  125.     CPaperSpaceWizard* pSheet = (CPaperSpaceWizard*)GetParent();
  126.     pSheet->m_PSInfo->bPaperOrientation = 1;
  127.  
  128. }
  129.  
  130. BOOL CPaperOrientation::OnWizardFinish() 
  131. {
  132.     // TODO: Add your specialized code here and/or call the base class
  133.  
  134.     CPaperSpaceWizard* pSheet = (CPaperSpaceWizard*)GetParent();
  135.     BSTR bstrPsName;
  136.     HRESULT hRes = E_FAIL;
  137.     PaperSpace *pPs = NULL;
  138.     IDispatch *pDisp = NULL;
  139.     try
  140.     {
  141.         bstrPsName = pSheet->m_PSInfo->cstrPSpaceName.AllocSysString ();
  142.         hRes = pSheet->m_pPss->Add(bstrPsName, &pDisp);
  143.         CHECK_HRESULT(hRes)
  144.         hRes = pDisp->QueryInterface (IID_PaperSpace, (void**)&pPs);
  145.         CHECK_HRESULT(hRes)
  146.  
  147.         hRes = pPs->Activate();
  148.         CHECK_HRESULT(hRes)
  149.  
  150.     }
  151.     catch(...)
  152.     {
  153.         TRACE("CPaperOrientation::OnWizardFinish()");
  154.     }
  155.  
  156.     RELEASE(pPs);
  157.     RELEASE(pDisp)
  158.     
  159.     RELEASE(pSheet->m_pPss);
  160.  
  161.     return CPropertyPage::OnWizardFinish();
  162. }
  163.